#!/usr/bin/env python
# coding:utf-8
# @author heitfei

'''
udp time client using socket
'''
import socket

HOST = 'localhost'
PORT = 23567
ADDR = (HOST, PORT)
BUFFSIZE = 1024

udpSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)

while True:
    data = raw_input('> ')
    if not data:
        break
    udpSocket.sendto(data, ADDR)
    data, ADDR = udpSocket.recvfrom(BUFFSIZE)
    if not data:
        break
    print "recv =",data

udpSocket.close()
